<?php include "addNewDemot.php"; ?>

<?php 
    $demots = View::get('demots'); 
    $pager = View::get('pager');
?>

<div class="clear"></div>
<div class="round">
    <div class="round-head">
                <h2>Lista demotywatorów</h2>              
        </div>


        <div class="round-content">

                <div class="hidden filter-boxes">

                        <form>

                                <div class="filter-item">
                                        <label>Name</label>
                                        <input type="text" />
                                </div>

                                <div class="filter-item">
                                        <label>Type</label>
                                        <select multiple="multiple"><option>All records</option><option>Only publicated</option><option>Only deleted</option></select>
                                </div>

                                <div class="filter-item">
                                        <label>Publication date</label>
                                        From: <input class="date-input" type="text" />
                                        To: <input class="date-input" type="text" />
                                </div>

                                <div class="cl">
                                        <input type="button" class="btn filter-send" value="Filter results" /> <a class="filter-reset-button" href="" title="Reset filters">Reset filters</a> | <a class="filter-button" href="" title="Hide filters">Hide filters</a>
                                </div>

                        </form>

                </div>

                <table class="table-a" summary="Table">
                        <thead>
                                <tr>
                                        <th scope="col" class="chb"><input class="chall" type="checkbox" /></th>
                                        <th scope="col">IMG</tg>
                                        <th scope="col">ID</th>
                                        <th scope="col">Tytuł</th>
                                        <th scope="col"><a href="index.php?controller=demot&action=demot_sort&sort=0">Data utworzenia</a></th>
                                        <th scope="col"><a href="index.php?controller=demot&action=demot_sort&sort=1">Status</a></th>
                                        <th scope="col">Publiczny</th>
                                        <th scope="col">Typ</th>
                                        <th scope="col">+18</th>
                                        <th scope="col" style="width: 65px;">Options</th>
                                </tr>
                        </thead>
                        
                        <form action="index.php?controller=demot&action=change" method="POST">
                            <input type="hidden" name="page" value="<?php echo isset($_GET['page']) ? $_GET['page'] : 1 ?>"/>
                        <tbody>
                            <?php foreach ($demots as $d): ?>
                                <tr>
                                        <td><input type="checkbox" name="idx[]" value="<?php echo $d['id']; ?>"/></td>
                                        
                                        <td>
                                            <?php if (file_exists("./bank/demot/mini/".$d['id'].".jpg")): ?>
                                                <a href="index.php?controller=demot&action=showDemot&id=<?php echo $d['id'] ?>"><img class="demot-image" src="./bank/demot/mini/<?php echo $d['id'] ?>.jpg"/></a>
                                            <?php else: ?>
                                                <a href="index.php?controller=demot&action=showDemot&id=<?php echo $d['id'] ?>"><img class="demot-image" src="./bank/1.jpg" width="90" height="90"/></a>
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo $d['id']; ?></td>
                                        <td><?php echo $d['title']; ?></td>
                                        <td><?php echo $d['date']; ?></td>
                                        <td><?php echo DStatus::getString($d['id_statuses']); ?></td>
                                        <td><?php echo $d['is_active'] ? "Aktywny" : "ZABLOKOWANY"; ?> </td>
                                        <td><?php echo DStatus::getTypeString($d['id_type']); ?></td>
                                        <td><?php echo $d['for_adults'] ? "TAK" : "NIE"; ?></td>
                                        <td>
                                                <a href="index.php?controller=demot&action=edit&id=<?php echo $d['id']; ?>" class="table-icon edit" title="Edit"></a>
                                                <a href="index.php?controller=demot&action=delete&id=<?php echo $d['id']; ?>" class="table-icon delete" title="Delete"></a>
                                              
                                        </td>
                                </tr>                                
                            <?php endforeach; ?>
                            
                                <tr><td colspan="10">
                                        <select name="status">
                                            <?php foreach(DStatus::getArray() as $k => $v): ?>
                                                <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                        <input type="submit" value="Zmień status"/></td></tr>
                                
                        </tbody>
                        </form>
                </table>

                <div class="tab-summary">
                        <div class="pagination">
                                <div class="resultsInfo">
                                    <div style="text-align: center;">
                                        <?php echo $pager->Render(true); ?>
                                    </div>                                   
                                </div>
                        </div>

                        <div class="closePagination"></div>
                </div>
        </div>

</div>